﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web;
using System.Web.Security;
using Htss.Platform.Web;

namespace DreamBox.Web.Box.user
{
    public class dataBox:ControllerBox
    {
        public ActionResult Load()
        {
            if (Request.RequestType == "POST")
            {
                Model.User m = new Model.User();
                SetModel(m);
                DAL.User.UserInfo user = new DAL.User.UserInfo();
                if (Session["UserID"] != null)
                {
                    m.UserID = int.Parse(Session["UserID"].ToString());
                    if (user.Update(m))
                    {
                        BLL.Message.Jump(this, "信息修改成功", "/user/data", "1");
                    }
                }
            }
            DAL.PSelect ps = new DAL.PSelect();
            DataTable dt = ps.Select("dbox_User", "UserID,UserName,Tags,Sex,Signature,Location", "UserID=" + Session["UserID"]);
            if (dt.Rows.Count > 0)
            {
                ViewData["UserID"] = dt.Rows[0]["UserID"];
                ViewData["UserName"] = dt.Rows[0]["UserName"];
                ViewData["Tags"] = dt.Rows[0]["Tags"];
                ViewData["Sex"] = dt.Rows[0]["Sex"];
                ViewData["Signature"] = dt.Rows[0]["Signature"];
                ViewData["Location"] = dt.Rows[0]["Location"];

            }
            return View("user_data");
        }
    }
}
